package com.example.bms.serviceimpl;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.bms.entity.MultiQuestion;
import com.example.bms.mapper.MultiQuestionMapper;
import com.example.bms.service.MultiQuestionService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.List;


/**
 * @apiNote 用于实现对选择题增删改查
 * @author 任玥越
 * @email 3108289016@qq.com
 * @return ApiResult
 * @since 1.0.0
 */
@Service
@Transactional
public class MultiQuestionServiceImpl implements MultiQuestionService {

    @Autowired
    private MultiQuestionMapper multiQuestionMapper;
    /**
     * @apiNote 查询选择题题库
     * @param PaperId 试题id
     * @author 任玥越
     * @email 3108289016@qq.com
     * @return IPage<MultiQuestion>
     * @since 1.0.0
     */
    public List<MultiQuestion> findByIdAndType(Integer PaperId) {
        return multiQuestionMapper.findByIdAndType(PaperId);
    }

    /**
     * @apiNote 查询选择题题库
     * @author 任玥越
     * @param page 页数
     * @email 3108289016@qq.com
     * @return IPage<MultiQuestion>
     * @since 1.0.0
     */
    @Override
    public IPage<MultiQuestion> findAll(Page<MultiQuestion> page) {
        return multiQuestionMapper.findAll(page);
    }

    /**
     * @apiNote 查询最后一条记录的questionId
     * @author 任玥越
     * @email 3108289016@qq.com
     * @return MultiQuestion
     * @since 1.0.0
     */
    @Override
    public MultiQuestion findOnlyQuestionId() {
        return multiQuestionMapper.findOnlyQuestionId();
    }
    /**
     * @apiNote 增加选择题题库试题
     * @param multiQuestion 选择题实体类
     * @author 任玥越
     * @email 3108289016@qq.com
     * @return ApiResult
     * @since 1.0.0
     */
    @Override
    public int add(MultiQuestion multiQuestion) {
        return multiQuestionMapper.add(multiQuestion);
    }
    /**
     * @apiNote 查询试卷ID
     * @author 任玥越
     * @email 3108289016@qq.com
     * @return List<Integer>
     * @since 1.0.0
     */
    @Override
    public List<Integer> findBySubject(String subject, Integer pageNo) {
        return multiQuestionMapper.findBySubject(subject,pageNo);
    }
}
